package tcp.heartbeat;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class HeartbeatListener implements Runnable{

	private int portNumber ;
	public HeartbeatListener(int portNumber) {
		this.portNumber = portNumber;
	}
	public void run() {
			try {
				ServerSocket heartbeServerSocket = new ServerSocket(this.portNumber);
				while(heartbeServerSocket.isBound()){
					System.out.println("Socket bound");
					Socket test = heartbeServerSocket.accept();
					System.out.println("Heartbeat check from: "+test.getInetAddress().getHostName());
					test.close();
	
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
	}

	
	
}
